package ch.sv7.tool.dbmanager.db.difference;

import ch.sv7.tool.dbmanager.db.TableSchema;

public abstract class AbstractTableDifference implements SchemaDifference, Comparable {

	private TableSchema expectedTableSchema;
	private TableSchema actualTableSchema;

	public AbstractTableDifference(TableSchema expectedtableSchema, TableSchema actualTableSchema) {
		this.expectedTableSchema = expectedtableSchema;
		this.actualTableSchema = actualTableSchema;
	}

	public String getTableName() {
		if (actualTableSchema != null) {
			return actualTableSchema.getName();
		} else {
			return expectedTableSchema.getName();
		}
	}

	public String getMessage(){
		return "Table [" + getTableName() + "]";
	}

	public TableSchema getExpectedTableSchema() {
		return expectedTableSchema;
	}

	public TableSchema getActualTableSchema() {
		return actualTableSchema;
	}

	public boolean isBlocker() {
		// TODO Auto-generated method stub
		return false;
	}

	public String toString() {
		return getMessage();
	}

	/**
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(Object o) {
		if (!(o instanceof AbstractTableDifference)){
			return 0;
		}
		AbstractTableDifference td = (AbstractTableDifference)o;
		return getTableName().compareTo(td.getTableName());
	}
	
	
}
